package axdoc.rule.check.impl;

import com.alibaba.fastjson.JSONObject;

import axdoc.rule.check.AbsCheck;
import axdoc.rule.check.LoadChecksUtil;
import axdoc.util.StringUtils;

public class CheckTitleRule extends AbsCheck {

	public CheckTitleRule() {
		super();
	}

	public CheckTitleRule(String titles) {
		this.titles = titles;
		this.cname = this.getClass().getName();
	}

	public String titles;

	public String getTitles() {
		return titles;
	}

	public void setTitles(String titles) {
		this.titles = titles;
	}

	@Override
	public boolean check(JSONObject obj) {
		String title = obj.getString("title");
		LoadChecksUtil.logger.info("[校验医生职称][titles:" + titles + "][title:" + title + "]");
		if (StringUtils.isEmpty(titles) || titles.equals("0")) {
			return true;
		} else {
			if (!titles.contains(title)) {
				LoadChecksUtil.logger.info("[校验医生职称][医生职称不匹配]");
				return false;
			} else if (StringUtils.isEmpty(title)) {
				LoadChecksUtil.logger.info("[校验医生职称][医生没有职称]");
				return false;
			}
		}
		return true;
	}

}
